<#macro paginate currentPage totalPage actionUrl urlParas="">
  <#if (totalPage <= 0)><#return></#if>
  <#local startPage = currentPage - 4>
  <#if (startPage < 1)><#local startPage = 1></#if>

  <#local endPage = currentPage + 4>
  <#if (endPage > totalPage)><#local endPage = totalPage></#if>
  <#if (currentPage <= 4)>
    <#local startPage = 1>
  </#if>
  <#if ((totalPage - currentPage) < 4)>
    <#local endPage = totalPage>
  </#if>
<ul>
  <#if (currentPage > 1)>
    <li><a href="${actionUrl}-#{1}${urlParas!}">&lt;&lt;</a></li>
    <li><a href="${actionUrl}-#{currentPage - 1}${urlParas!}">Prev</a></li>
  </#if>
  <#list startPage..endPage as i>
    <#if currentPage == i>
      <li class="active"><a>#{i}</a></li>
    <#else>
      <li><a href="${actionUrl}-#{i}${urlParas!}">#{i}</a></li>
    </#if>
  </#list>
  <#if (currentPage < totalPage)>
    <li><a href="${actionUrl}-#{currentPage + 1}${urlParas!}">Next</a></li>
    <li><a href="${actionUrl}-#{totalPage}${urlParas!}">&gt;&gt;</a></li>
  </#if>
</ul>
</#macro>
